//
//  TKYTreatHandelController.m
//  StationHouseHelper
//
//  Created by apple on 2018/7/6.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYTreatHandelController.h"
#import "TKYTreatHandelCell.h"
#import "PPBadgeView.h"
#import "TKYChangeStationHouseController.h"
#import "TKYMessageCenterController.h"
#import "UIViewController+CWLateralSlide.h"
#import "TKYTreatHandelDetitleController.h"

//待办cellID
#define KTreatHandelCellID @"TKYTreatHandelCell"
@interface TKYTreatHandelController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong)BaseTabelView *tableV;
@end

@implementation TKYTreatHandelController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置界面
    [self setupUI];
}

/**
 设置界面
 */
- (void)setupUI{
    self.navigationItem.title = @"待办";
    self.navigationController.navigationBar.barTintColor = KNavColor;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:19.0]}];
    
     self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"nav"] style:UIBarButtonItemStylePlain target:self action:@selector(changeStationHouseBarButtonItem:)];
    
    //导航右侧的消息按钮
    UIButton *rightBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBarButton setImage:[UIImage imageNamed:@"message"] forState:UIControlStateNormal];
    rightBarButton.frame = CGRectMake(0, 0, 40, 40);
    [rightBarButton addTarget:self action:@selector(messageCerterAction:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightBarButton];
    // 1.2 右边
    [self.navigationItem.rightBarButtonItem pp_addBadgeWithText:nil];
    [self.navigationItem.rightBarButtonItem pp_moveBadgeWithX:0 Y:6];
    [self.navigationItem.rightBarButtonItem pp_setBadgeFlexMode:PPBadgeViewFlexModeHead];
    //隐藏消息按钮的小红点
    // [self.navigationItem.rightBarButtonItem pp_hiddenBadge ];
    [self.view addSubview:self.tableV];
}

#pragma mark-- 按钮的点击事件
//切换站点
- (void)changeStationHouseBarButtonItem:(UIBarButtonItem *)barButtonItem{
    TKYChangeStationHouseController *vc = [[TKYChangeStationHouseController alloc] init];
    vc.drawerType = DrawerTypeMaskLeft;
    // [self cw_pushViewController:vc drewerHiddenDuration:0.01];
    [self cw_showDrawerViewController:vc animationType:CWDrawerAnimationTypeMask configuration:nil];
}

//切换消息界面
- (void)messageCerterAction:(UIBarButtonItem *)barButtonItem{
    TKYMessageCenterController *messageCenterVC = [TKYMessageCenterController new];
    
    [self.navigationController pushViewController:messageCenterVC animated:YES];
    
}

#pragma mark-- UITableViewDelegate,UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TKYTreatHandelCell *cell = [tableView dequeueReusableCellWithIdentifier:KTreatHandelCellID];
    
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //消息界面
    TKYTreatHandelDetitleController *treatHandelDetitleVC = [[TKYTreatHandelDetitleController alloc]init];
    
    [self.navigationController pushViewController:treatHandelDetitleVC animated:YES];
}

//
- (BaseTabelView *)tableV{
    if (_tableV == nil) {
        _tableV = [[BaseTabelView alloc]initWithFrame:CGRectMake(0, MyNavBarHeight, kScreenWidth, kScreenHeight - MyNavBarHeight) style:UITableViewStylePlain];
        _tableV.dataSource = self;
        _tableV.delegate = self;
        [_tableV registerNib:[UINib nibWithNibName:@"TKYTreatHandelCell" bundle:nil] forCellReuseIdentifier:KTreatHandelCellID];
    }
    return _tableV;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
